#include "task.h"
#include "core.h"
#include "simul.h"
#include "priority.h"
#include "rm_schedule.h"
#ifndef RESOURCE_H
#define RESOURCE_H

#endif // RESOURCE_H

typedef struct Resource
{
   bool is_global;
   int resource_type;
   int resource_on_core;
   bool is_bind=false;
   bool is_used;
   int used_task_id;
   int ceiling_prior;
   ready_queue_node *resource_suspend_queue;
}Resource;

extern int cluster_ceiling_prio ;
extern  Resource resource[20];

int get_resourcenum();

void resource_type_update();

bool SRT_task_try_to_get_local_resource(Task *task,Core *core,Resource *resource);

bool SRT_task_try_to_get_global_resource(Task *task,Core *newcore,Core *lastcore,Resource *resource);

bool HRT_task_try_to_get_local_resource(Task *task,Core *core,Resource *resource);

bool HRT_task_try_to_get_global_resource(Task *task,Core *newcore,Core *lastcore,Resource *resource);

void resource_enqueue(Task *task,Resource *resource);

void task_release_resource(Task *task,Resource *resource,Core *core);

void resource_init(int resource_type);

void resource_denqueue(Task *task,Resource *resource);

void resource_bind(Task *task);
